package com.itheima.mapper;

import com.itheima.pojo.User;
import com.itheima.qo.PageQuery;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    long count(User t);

    List<User> list(PageQuery<User> pageQuery);

    @Select("select * from tb_user where username=#{username} and password=#{password}")
    User login(User user);

    @Select("select * from tb_user where username=#{username}")
    User getByUsername(String username);

    @Insert("insert into tb_user(name,gender,username,password,role,phone,status,create_time) values(#{name},#{gender},#{username},#{password},#{role},#{phone},#{status},#{createTime})")
    void add(User user);

    @Select("select * from tb_user where id=#{id}")
    User getById(Integer id);

    @Update("update tb_user set name=#{name},gender=#{gender},username=#{username},password=#{password},role=#{role},phone=#{phone},status=#{status} where id=#{id}")
    void update(User user);

    @Delete("delete from tb_user where id= #{id}")
    void deleteById(Integer id);
}
